import os
import sys

# 请在此输入您的代码
# 答案：print(70910)
import datetime
start = datetime.date(1900,1,1)
end = datetime.date(9999,12,31)

def isTrue(year,month,day):
    a = sum(map(int,list(str(year))))
    b= sum(map(int,list(str(month)+str(day))))
    return a == b
cnt = 0
while start < end:
  if isTrue(start.year,start.month,start.day):
    cnt+=1
  start += datetime.timedelta(days=1)
print(cnt)

# print(70910)
